package com.xsy.carRental.mapper;

import com.github.pagehelper.Page;
import com.xsy.carRental.dto.CustomerPageQueryDTO;
import com.xsy.carRental.dto.CustomerSearchQueryDTO;
import com.xsy.carRental.entity.Customer;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface CustomerMapper {

    /**
     * 新用户注册
     *
     * @param customer
     */
    @Insert("insert into customer (customer_id,name,email,phone,driver_license_number,created_at)" +
            "values (#{customerId},#{name},#{email},#{phone},#{driverLicenseNumber},#{createdAt}) ")
    void add(Customer customer);

    /**
     * 分页查询用户
     *
     * @param customerPageQueryDTO
     * @return
     */
    Page<Customer> pageQuery(CustomerPageQueryDTO customerPageQueryDTO);

    /**
     * 根据id删除用户
     *
     * @param id
     */
    @Delete("delete from customer where customer_id=#{id}")
    void deleteById(int id);

    /**
     * 根据三个可选条件分页查询用户
     *
     * @param searchQueryDTO
     * @return
     */
    Page<Customer> SearchQuery(CustomerSearchQueryDTO searchQueryDTO);
}
